using UnityEngine;
using System.Collections;

public class HealthBar : MonoBehaviour
{
	private Rect lifeBarRect;
	public Texture2D lifeBar;
	private float LifeBarWidth = 50;
	
	public float currentLife;
	public float maxLife;
	
	public void setPos(Vector3 pos)
	{
		lifeBarRect.x = pos.x - (LifeBarWidth/2);
		lifeBarRect.y = Screen.height - pos.y - 25;
	}
	
	void OnGUI()
	{
		lifeBarRect.width = LifeBarWidth * (currentLife/maxLife);
		lifeBarRect.height = 10;
		
	    GUI.DrawTexture(lifeBarRect, lifeBar);
	}
}